package com.zztl.infiniteBand.util.language

import android.content.Context
import android.content.SharedPreferences
import com.zztl.infiniteBand.storage.BillPreference

import java.util.Locale

/**
 * @author swl
 * date 2019/8/12 17:42
 */
class SPUtil(context: Context) {
    private val SP_NAME = "language_setting"
    private val TAG_LANGUAGE = "language_select"
    private val TAG_SYSTEM_LANGUAGE = "system_language"

//    private val mSharedPreferences: SharedPreferences

    var systemCurrentLocal = Locale.ENGLISH

    val selectLanguage: Int
        get() = BillPreference.getApp(TAG_LANGUAGE, 0) as Int

/*

    init {
        mSharedPreferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE)
    }
*/


    fun saveLanguage(select: Int) {
        BillPreference.putApp(TAG_LANGUAGE, select)
    }

    companion object {
        @Volatile
        private var instance: SPUtil? = null

        fun getInstance(context: Context): SPUtil? {
            if (instance == null) {
                synchronized(SPUtil::class.java) {
                    if (instance == null) {
                        instance = SPUtil(context)
                    }
                }
            }
            return instance
        }
    }
}
